import type { IDict } from './entity';
import type { IPageParams } from '@/types/table'
import request from '@/api/request'

export function getDicts(data: IPageParams) {
  return request({
    url: '/sys/dict/list',
    method: 'get',
    data,
    loading: true
  })
}

export function getDictById(id: number) {
  return request({
    url: `/sys/dict/info/${id}`,
    method: 'get'
  })
}

export function deleteDictById(id: number) {
  return request({
    url: '/sys/dict/delete',
    method: 'post',
    data: [id],
    loading: true
  })
}

export function saveDict(data: IDict) {
  return request({
    url: `/sys/dict/${data.id ? 'update' : 'save'}`,
    method: 'post',
    data,
    loading: true
  })
}